/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.dao.impl;

import com.qdu.dao.UserDao;
import com.qdu.entity.Activity;
import com.qdu.entity.Users;
import com.qdu.util.DatabaseUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.catalina.User;

/**
 *
 * @author Zoey
 */
public class UserDaoImpl implements UserDao {

    @Override
    public void addUserRole(Users user) {

        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        List<Activity> list = new ArrayList<>();

        try {
            con = DatabaseUtil.getConnection();
            ps = con.prepareStatement("insert into Users(Uid,Upwd,Ugender,Ubirthday,UIDnumber,Uemail,Utelnumber,Ucity,Ucareer) values (?,?,?,?,?,?,?,?,?)");
            ps.setString(1, user.getUid());
            ps.setString(2, user.getUpwd());
            ps.setString(3, user.getUgender());
            ps.setString(4, user.getUbrithday());
            ps.setString(5, user.getUIDnumber());
            ps.setString(6, user.getUemail());
            ps.setString(7, user.getUtelnumber());
            ps.setString(8, user.getUcity());
            ps.setString(9, user.getUcareer());
            int result=ps.executeUpdate();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DatabaseUtil.close(rs, ps, con);
        }

    }

}
